package com.api.shopapi.mapper;

import com.api.shopapi.entity.NursingRecordPositionLack;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
@Mapper
public interface NursingRecordPositionLackMapper {

    @Insert("insert into nursing_record_position_lack " +
            "(NursingRecordPositionLackCode," +
            "NursingRecordPositionCode," +
            "InstitutionCode," +
            "GovernmentCode," +
            "CreateTime" +
            ") " +
            "values (" +
            "#{nursingRecordPositionLack.NursingRecordPositionLackCode} ," +
            "#{nursingRecordPositionLack.NursingRecordPositionCode} ," +
            "#{nursingRecordPositionLack.InstitutionCode} ," +
            "#{nursingRecordPositionLack.GovernmentCode} ," +
            "#{nursingRecordPositionLack.CreateTime}" +
            ")")
    int insert(@Param("nursingRecordPositionLack") NursingRecordPositionLack nursingRecordPositionLack);

    @Delete("delete from nursing_record_position_lack where nursingRecordPositionLackCode=#{nursingRecordPositionLackCode} ")
    int delete(@Param("nursingRecordPositionLackCode") String nursingRecordPositionLackCode);

    @Update("update nursing_record_position_lack" +
            " set" +
            " NursingRecordPositionCode=#{nursingRecordPositionLack.NursingRecordPositionCode}, " +
            " where nursingRecordPositionLackCode=#{nursingRecordPositionLack.nursingRecordPositionLackCode} ")
    int update(@Param("nursingRecordPositionLack") NursingRecordPositionLack nursingRecordPositionLack);


    @Select("select  * from nursing_record_position_lack where nursingRecordPositionLackCode=#{nursingRecordPositionLackCode} limit 1")
    NursingRecordPositionLack getByCode(@Param("nursingRecordPositionLackCode") String nursingRecordPositionLackCode);

    @Select("select * from nursing_record_position_lack where nursingRecordPositionCode=#{nursingRecordPositionCode} order by CreateTime desc")
    List<NursingRecordPositionLack> listByNursingRecordPositionCode(@Param("nursingRecordPositionCode") String nursingRecordPositionCode);


    @Select("select * from nursing_record_position_lack" +
            " where" +
            " governmentCode=#{governmentCode}" +
            " and (CreateTime between #{startTime} and #{endTime})"+
            " order by CreateTime desc")
    List<NursingRecordPositionLack> listByGovCodeTime(@Param("governmentCode") String governmentCode,
                                                      @Param("startTime") String startTime,
                                                      @Param("endTime") String endTime);



    @Select("select * from nursing_record_position_lack" +
            " where" +
            " governmentCode=#{governmentCode}" +
            " order by CreateTime desc")
    List<NursingRecordPositionLack> listByGovCode(@Param("governmentCode") String governmentCode);



}
